<?php /*
	
*/ ?>
<?php include("inc/head.inc.php"); ?>
<body>
<table width="824" border="0" cellpadding="0" cellspacing="0"  align="center">
  <tr>
   <td class="headerclass"><?php include(INC."top.inc.php") ?></td>
  </tr>
  <tr>
    <td valign="top" class="maincontainer">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr><td width="235" valign="top"class="leftmenuback"><?php include(INC."left.inc.php")?></td>
        <td valign="top">
			<div class="pageheader">Products</div>
			<div class="sortoptions">Sort By: <a href="products.php?sort=new">Newest First</a> :: <a href="products.php?sort=htol">Price Descending</a> :: <a href="products.php?sort=ltoh">Price Ascending</a></div>
		<?php			
			if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='new')
			{
			$sql = "SELECT tblproducts.intprodid, tblproducts.intproddefaultimg, tblproducts.decprice, tblproddesc.varprodname, tblproddesc.txtdesc FROM `tblproducts` INNER JOIN `tblproddesc` ON tblproddesc.intid = tblproducts.intprodid WHERE tblproducts.intstatus=0 ORDER BY tblproducts.dtaddeddate ASC";
			}
			if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='htol')
			{
			$sql = "SELECT tblproducts.intprodid, tblproducts.intproddefaultimg, tblproducts.decprice, tblproddesc.varprodname, tblproddesc.txtdesc FROM `tblproducts` INNER JOIN `tblproddesc` ON tblproddesc.intid = tblproducts.intprodid WHERE tblproducts.intstatus=0 ORDER BY tblproducts.decprice DESC";
			}
			if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='ltoh')
			{
			$sql = "SELECT tblproducts.intprodid, tblproducts.intproddefaultimg, tblproducts.decprice, tblproddesc.varprodname, tblproddesc.txtdesc FROM `tblproducts` INNER JOIN `tblproddesc` ON tblproddesc.intid = tblproducts.intprodid WHERE tblproducts.intstatus=0 ORDER BY tblproducts.decprice ASC";
			}
			else if(!isset($_REQUEST['sort']))
			{
			$sql = "SELECT tblproducts.intprodid, tblproducts.intproddefaultimg, tblproducts.decprice, tblproddesc.varprodname, tblproddesc.txtdesc FROM `tblproducts` INNER JOIN `tblproddesc` ON tblproddesc.intid = tblproducts.intprodid WHERE tblproducts.intstatus=0 ORDER BY tblproducts.dtaddeddate ASC";
			}
			
			$products=$n02586916_db->select($sql);
			if(count($products)>0)
			{
				$colcount=0;
				for($h=0;$h<count($products);$h++)
				{
					$productname=$products[$h]['varprodname'];
					$productdesc=myTruncate($products[$h]['txtdesc'], 160);
					if (file_exists("images/product/midium/".$products[$h]['intproddefaultimg'])) {
						$image = "images/product/midium/".$products[$h]['intproddefaultimg'];
					} else {
						$image = "images/product/noimage.jpg";
					}
					$productprice=stripslashes($products[$h]['decprice']);
					$prodid=stripslashes($products[$h]['intprodid']);
				
					if ($colcount==0) {
						echo "<div id=\"leftblock\"><div id=\"leftheader\">".stripslashes($productname)."</div><div id=\"leftcontent\"><div style=\"float:left;padding-right:3px;padding-bottom:3px;\"><img src=\"$image\" border=\"0\" width=\"80\" /></div>".stripslashes($productdesc)."<p class=\"pricetag\">&pound;$productprice</p><p class=\"byline\"><a href=\"proddetail.php?proid=$prodid\" class=\"aa\"><img src=\"images/buynow.jpg\" border=\"0\" /></a></p></div></div>";
						$colcount=1;
					} else {
						echo "<div id=\"rightblock\"><div id=\"rightheader\">".stripslashes($productname)."</div><div id=\"rightcontent\"><div style=\"float:left;padding-right:3px;padding-bottom:3px;\"><img src=\"$image\" border=\"0\" width=\"80\" /></div>".stripslashes($productdesc)."<p class=\"pricetag\">&pound;$productprice</p><p class=\"byline\"><a href=\"proddetail.php?proid=$prodid\" class=\"aa\"><img src=\"images/buynow.jpg\" border=\"0\" /></a></p></div></div>";
						$colcount=0;
					}
				}
			} else { 
				echo "<div align=\"center\">No products found at this time please try again later</div>";
			}
		?>

    </td>
  </tr>
  </table>
  <tr>
    <td><?php include "inc/bottom.inc.php"; ?></td>
  </tr>
</table>
</body>
</html>